﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;

namespace luanvanFinal
{
    /// <summary>
    /// Interaction logic for wdRiskFirst1.xaml
    /// </summary>
    public partial class wdRiskFirst1 : Window
    {
        public wdRiskFirst1()
        {
            InitializeComponent();
            loadProject();
        }

        public void loadProject()
        {
            String strSQL = "select proName from project";
            clsConnect ketnoi = new clsConnect();
            ketnoi.openConnection();
            SqlDataAdapter da = new SqlDataAdapter(strSQL, ketnoi.Connection);
            DataTable dt = new DataTable();
            da.Fill(dt);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cbPro.Items.Add(dt.Rows[i][0]);
            }
            cbPro.SelectedIndex = 0;
            ketnoi.closeConnection();
        }
       
        private void btnShow_Click(object sender, RoutedEventArgs e)
        {
            clsProject project = new clsProject();
            wdRiskFirst riskFirst = new wdRiskFirst();
            riskFirst.IdProject = Convert.ToInt32(project.getIdFromName(cbPro.Text));
            riskFirst.Show();
        }

        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            clsProject pro = new clsProject();
            wdRisk wdRiskFirstEdit = new wdRisk();
            wdRiskFirstEdit.IdProject = Convert.ToInt32(pro.getIdFromName(cbPro.Text));
            wdRiskFirstEdit.Show();
        }
    }
}
